# 设置CMake最低版本要求为3.8
cmake_minimum_required(VERSION 3.8)
# 设置工程名称：DemoPrograms，编程语言：C
project(DemoPrograms LANGUAGES C)
# 设置C语言的标准为C99，并开启标准检查
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_FLAGS "-Wall")
# 链接数学库
LINK_LIBRARIES(m)

# 下面使用add_executable功能列出所有需要编译的程序

## 编译ch1-hello程序，程序源代码是Chapter1/hello.c
add_executable(ch1-hello chapter1/hello.c)

## 编译示例程序1.1（demo1_1），程序源代码是Chapter1/demo1_1.c
add_executable(demo1_1 chapter1/demo1_1.c)

## 编译示例程序1.2
add_executable(demo1_2 chapter1/demo1_2.c)

## 编译示例程序1.3
add_executable(demo1_3 chapter1/demo1_3.c)

## 第二章
add_executable(ch2_1 chapter2/ch2.1.c)

## 第三章
add_executable(X3-1 chapter3/X3-1.c)

## Chapter 5

add_executable(lec7_deadloop1 chapter5/lec7_dead_loop1.c)
add_executable(demo5_1 chapter5/demo5_1.c)
add_executable(demo5_4 chapter5/demo5_4.c)
add_executable(lec8_print_multiplication_table chapter5/lec8_print_multiplication_table.c)
add_executable(demo5_8 chapter5/demo5_8.c)
add_executable(demo5_9 chapter5/demo5_9.c)
add_executable(demo5_9_v2 chapter5/demo5_9_v2.c)
add_executable(how_fast_my_computer chapter5/how_fast_my_computer.c)
add_executable(demo5_11_part1 chapter5/demo5_11_part1.c)
add_executable(demo5_11_part2 chapter5/demo5_11_part2.c)
add_executable(demo5_11 chapter5/demo5_11.c)

## Chapter 6

add_executable(lec9_uninitialized_array chapter6/lec9_uninitialized_array.c)
add_executable(lec9_out_of_index_array chapter6/lec9_out_of_index_array.c)
add_executable(demo6_3 chapter6/demo6_3.c)
add_executable(demo6_3_large_data chapter6/demo6_3_large_data.c)
add_executable(printf_out_range chapter6/printf_out_range.c)
add_executable(lec10_read_multi_string chapter6/lec10_read_multi_string.c)
add_executable(lec10_gets_demo chapter6/lec10_gets_demo.c)
add_executable(demo6_8 chapter6/demo6_8.c)
add_executable(demo6_9 chapter6/demo6_9.c)

## Chapter 7
add_executable(demo_return_value_type chapter7/demo_return_value_type.c)
add_executable(function_declaration chapter7/function_declaration.c)
add_executable(function_add_demo chapter7/function_add_demo.c)
add_executable(demo_arr_name chapter7/demo_arr_name.c)
add_executable(demo7_14 chapter7/demo7_14.c)
add_executable(demo_static_var chapter7/demo_static_var.c)
add_executable(demo_recursive_var chapter7/demo_recursive_var.c)
add_executable(modify_array chapter7/modify_array.c)

## Chapter 8
add_executable(address_of_variable chapter8/address_of_variable.c)
add_executable(address_of_array_and_function chapter8/address_of_array_and_function.c)
add_executable(demo_pointer_usage chapter8/demo_pointer_usage.c)
add_executable(demo_vec_calc chapter8/demo_vec_calc.c)
add_executable(pointer_of_2d_array chapter8/pointer_of_2d_array.c)
add_executable(array_as_func_parameter chapter8/array_as_func_parameter.c)
add_executable(demo8_8 chapter8/demo8_8.c)
add_executable(demo8_10 chapter8/demo8_10.c)
add_executable(find_x_max chapter8/find_x_max.c)
add_executable(string_storage chapter8/string_storage.c)
add_executable(string_copy chapter8/string_copy.c)
add_executable(test_func_pointer chapter8/test_func_pointer.c)
add_executable(generic_sort chapter8/generic_sort.c)
add_executable(find_score chapter8/find_score.c)
add_executable(demo8_27 chapter8/demo8_27.c)
add_executable(find_max_str chapter8/find_max_str.c)
add_executable(main_args chapter8/main_args.c)
add_executable(demo8_30 chapter8/demo8_30.c)
add_executable(stutest chapter8/test.c)
add_executable(wrong_pointer_usage chapter8/wrong_pointer_usage.c)
add_executable(memory_leak chapter8/memory_leak.c)

## Chapter9
add_executable(structure_storage chapter9/structure_storage.c)
add_executable(demo9_2 chapter9/demo9_2.c)
add_executable(structure_array_init chapter9/structure_array_init.c)
add_executable(demo9_6 chapter9/demo9_6.c)
add_executable(demo_student_score chapter9/demo_student_score.c)
add_executable(demo9_9 chapter9/demo9_9.c)
add_executable(demo_dynamic_linked_list_with_indirect_pointer chapter9/demo_dynamic_linked_list_with_indirect_pointer.c)
add_executable(demo_dynamic_linked_list_without_indirect_pointer chapter9/demo_dynamic_linked_list_without_indirect_pointer.c)


## Chapter10
add_executable(text_file_openclose chapter10/text_file_openclose.c)
add_executable(demo10_1 chapter10/demo10_1.c)
add_executable(demo10_2 chapter10/demo10_2.c)
add_executable(demo10_3 chapter10/demo10_3.c)
add_executable(demo10_4 chapter10/demo10_4.c)
add_executable(demo10_4_check chapter10/demo10_4_check.c)
add_executable(demo10_4_load_save chapter10/demo10_4_load_save.c)
add_executable(demo10_5 chapter10/demo10_5.c)
add_executable(demo10_6 chapter10/demo10_6.c)
add_executable(cat_prog chapter10/cat_prog.c)
add_executable(perror_demo chapter10/perror_demo.c)

## 实验作业代码
add_executable(sum_T1 lab_answer/和为T_解法1.c)
add_executable(sum_T2 lab_answer/和为T_解法2.c)
add_executable(HuiWenWanMei lab_answer/回文完美.c)
add_executable(ShanChuDanCi lab_answer/删除单词.c)
add_executable(ZiChuanTongJi lab_answer/字串统计.c)
add_executable(lab5_HuiXingQuShu lab_answer/lab5_回形取数.c)